<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

</head>

<body>

    <script>
        function isNumber(num) {
            return (num.trim() == '')
        }

        function calculater() {
            while (true) {
                let num = +prompt('1.加 2.减 3.乘 4.除 5.退出')
                if (num == 5) {
                    alert('退出')
                    break
                }

                let num1 = prompt('第一个数:')
                if (isNumber(num1)) {
                    alert('你输入的有问题')
                    continue
                }
                let num2 = prompt('第二个数:')
                if (isNumber(num2)) {
                    alert('你输入的有问题')
                    continue
                }
                num1 = Number(num1)
                num2 = Number(num2)
                console.log(num1);
                switch (num) {
                    case 1: alert(num1 + num2); continue;
                    case 2: alert(num1 - num2); continue;
                    case 3: alert(num1 * num2); continue;
                    case 4: alert(num1 / num2); continue;
                }
            }


        }

        calculater()
    </script>
</body>

</html>